

from pixiv.file_download import file_download
from config.user_setting import IMAGE_DOWNLOAD_MODE
from pixiv.url_Queue_download import UrlQueue,Queue_thread_download
class FileSelectDownload():
    def __init__(self,session):
        self.s = session
        if IMAGE_DOWNLOAD_MODE == 'queueThread':
            self.q = UrlQueue()
            self.queue=Queue_thread_download(session,self.q)
            self.start = True
        else:
            self.file_download = file_download('',session)

    def downLoad(self,url):
        if IMAGE_DOWNLOAD_MODE == 'queueThread':
            if self.start:
                self.queue.queue_download()
                self.start =False
            self.q.put(url)
        elif IMAGE_DOWNLOAD_MODE == 'autoMode':
            self.file_download.setUrl(url)
            self.file_download.auto_select_download()
        elif IMAGE_DOWNLOAD_MODE == 'multiThread':
            self.file_download.setUrl(url)
            self.file_download.download_thread()
        elif IMAGE_DOWNLOAD_MODE == 'singleThread':
            self.file_download.setUrl(url)
            self.file_download.download()
